<template>
  <div>
    <div>
      <FormPanel
        ref="formPanel"
        :list="formList"
        :cols="2"
        :labelWidth="110"
        :formType="type"
        :isSubmitBtn="false"
        @formChange="formChangeHandle"
      />
    </div>
    <div
      :style="{
        position: 'absolute',
        left: 0,
        bottom: 0,
        right: 0,
        zIndex: 9,
        borderTop: '1px solid #e9e9e9',
        padding: '10px 20px',
        background: '#fff',
        textAlign: 'right'
      }"
    >
      <el-Button type="primary" @click="closeDialog">关 闭</el-Button>
    </div>
  </div>
</template>
<script>
  import { dictionary } from '@/utils/dictMixin';
  import { getContactMange4 } from '@/api/repair/queryStatistics/queryAccounts';
  // 机修快保交车率
  export default {
    name: 'whmClaimParams',
    mixins: [dictionary],
    props: {
      formData: {
        type: Object,
        default: () => ({})
      }
    },
    data() {
      this.conf = { add: '保 存', edit: '修 改' };
      this.saveData = null;
      return {
        formList: this.createFormList()
      };
    },
    computed: {},
    created() {
      this.init();
    },
    methods: {
      createFormList() {
        return [
          {
            type: 'RANGE_DATE',
            label: '日期',
            fieldName: 'startTime|stopTime',
            disabled: true,
            placeholder: '',
            selfCols: 2,
          },
          {
            type: 'INPUT',
            label: '机修快保审核台次',
            fieldName: 'JSGDS',
            disabled: true,
            selfCols: 2,
          },

          {
            type: 'INPUT',
            label: '平均维修时长',
            fieldName: 'PJSC',
            disabled: true,
            selfCols: 2
          },
          {
            type: 'INPUT',
            label: '准时交车台次',
            fieldName: 'zsjctc',
            disabled: true,
            selfCols: 2,
          },
          {
            type: 'INPUT',
            label: '准时交车率',
            fieldName: 'ZSL',
            disabled: true,
            selfCols: 2,
            descOptions: {
              content: '%'
            }
          },
          {
            type: 'TEXT_AREA',
            label: ' 机修快保准时交车率公式:',
            fieldName: 'remark',
            selfCols: 2,
            maxlength: 32,
            disabled: true,
            placeholder: ' 维修时长：审核时间—接车时间\t\t\n' +
              ' 准时交车：审核时间早于约定交车时间\t\t\n' +
              ' 准时交车率：准时交车台次 / 审核台次 * 100%'
          }
        ];
      },

      async getParams() {
        let res = (await getContactMange4(this.formData)).data.rows;
        this.formList.forEach(x => {
          if(x.fieldName!= 'startTime|stopTime'){
            x.initialValue = res[0][x.fieldName];
          }
        });
      },
      formChangeHandle(val) {
        this.saveData = val;
      },
      // async saveDialog() {
      //   const data = this.$refs.formPanel.SUBMIT_FORM();
      //   let res = await updateUsedCarParams(data);
      //   window.console.log(5);
      //   window.console.log(res.data);
      //   if (res.resultCode === 200) {
      //     // 成功返回200
      //     return this.$notify({
      //       title: '提示信息',
      //       message: '保存成功',
      //       type: 'success'
      //     });
      //   }
      // },
      init() {
        this.formList.find(x=>x.fieldName==='startTime|stopTime').initialValue=this.formData;
        this.getParams();
      },
      closeDialog(param) {
        this.$emit('close', false, param);
      }
    }
  };
</script>

<style lang="less" scoped></style>
